package club.babyf.nativeai.demo.spi;

import java.util.ServiceLoader;

/**
 * SPIMainApplication.
 *
 * @author zhanglei.
 * @date 2025/3/25 14:28.
 * @description SPI验证.
 */
public class SPIVerify {

    public static void main(String[] args) {
        // SPI加载入口，与业务无关，验证SPI.
        ServiceLoader<DatabaseService> services = ServiceLoader.load(DatabaseService.class);
        System.out.println("Available database services:");
        for (DatabaseService service : services) {
            System.out.println("- " + service.getDatabaseType());
            service.connect();
            System.out.println();
        }
    }

}
